package st.business.tepth.business.taskallocation;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import st.business.tepth.R;
import st.business.tepth.business.bean.TaskAllocationBean;

/**
 * @author zhangyu
 * @date 2019/2/26
 */
public class TaskAllocationAdapter extends BaseQuickAdapter<TaskAllocationBean, BaseViewHolder> {
    public TaskAllocationAdapter(int layoutResId, @Nullable List<TaskAllocationBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, TaskAllocationBean item) {
        helper.setText(R.id.tv_driver_name, item.getUser_name());
        helper.setText(R.id.tv_bus_number, item.getVehicle_no());
        helper.setText(R.id.tv_work_type, item.getTypeName());
        helper.setText(R.id.tv_report_time, item.getAddTime());
        //helper.setText(R.id.tv_arrive_time, TimeUtils.secondToString(item.getTime()));
        helper.setText(R.id.tv_arrive_time, item.getArrivalTime());
        helper.setText(R.id.tv_location, item.getFactory_area_name());
        helper.setText(R.id.tv_work_person, item.getWorker_name());
        helper.setText(R.id.tv_pass_person, item.getPass_user_name());
        helper.setText(R.id.tv_finish_person, item.getComplete_user_name());
        helper.setText(R.id.tv_state, item.getStatus_name());
        helper.setText(R.id.tv_work_group, item.getOrgGroup());
        // if (item.getStatus() <= 3) {
        helper.setVisible(R.id.tv_operation, true);
        helper.setText(R.id.tv_operation, "分配任务");
        helper.addOnClickListener(R.id.tv_operation);
        helper.addOnClickListener(R.id.tv_modify_location);
        helper.addOnClickListener(R.id.tv_modify_classification);
        helper.addOnClickListener(R.id.tv_more);
//        } else {
//            helper.setText(R.id.tv_operation, "任务已分配");
//            helper.setVisible(R.id.tv_operation, false);
//        }
    }

    private String getType(int type) {
        String strType = "";
        switch (type) {
            case 1:
                strType = "小修";
                break;
            case 2:
                strType = "一级保养";
                break;
            case 3:
                strType = "二级保养";
                break;
            case 4:
                strType = "三级保养";
                break;
            case 5:
                strType = "电池保养";
                break;
        }
        return strType;
    }

    private String getStatus(int status) {
        String strStatus = "";
        switch (status) {
            case 1:
                strStatus = "已报修待回站";
                break;
            case 2:
                strStatus = "已回站待驻站接车";
                break;
            case 3:
                strStatus = "作业中";
                break;
            case 4:
                strStatus = "作业完成待司机接车";
                break;
            case 5:
                strStatus = "司机已接车";
                break;
        }
        return strStatus;
    }
}
